<!doctype html>
<html class="no-js">
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1" charset="UTF-8">
    <title>connect</title>
<link href="../../../../images/logo-icon.svg" rel="icon" type="image/svg">    <script>var pathToRoot = "../../../../";</script>
    <script>document.documentElement.classList.replace("no-js","js");</script>
    <script>const storage = localStorage.getItem("dokka-dark-mode")
    if (storage == null) {
        const osDarkSchemePreferred = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
        if (osDarkSchemePreferred === true) {
            document.getElementsByTagName("html")[0].classList.add("theme-dark")
        }
    } else {
        const savedDarkMode = JSON.parse(storage)
        if(savedDarkMode === true) {
            document.getElementsByTagName("html")[0].classList.add("theme-dark")
        }
    }
    </script>
<script type="text/javascript" src="https://unpkg.com/kotlin-playground@1/dist/playground.min.js" async></script>
<script type="text/javascript" src="../../../../scripts/sourceset_dependencies.js" async></script>
<link href="../../../../styles/style.css" rel="Stylesheet">
<link href="../../../../styles/main.css" rel="Stylesheet">
<link href="../../../../styles/prism.css" rel="Stylesheet">
<link href="../../../../styles/logo-styles.css" rel="Stylesheet">
<link href="../../../../styles/font-jb-sans-auto.css" rel="Stylesheet">
<script type="text/javascript" src="../../../../scripts/clipboard.js" async></script>
<script type="text/javascript" src="../../../../scripts/navigation-loader.js" async></script>
<script type="text/javascript" src="../../../../scripts/platform-content-handler.js" async></script>
<script type="text/javascript" src="../../../../scripts/main.js" defer></script>
<script type="text/javascript" src="../../../../scripts/prism.js" async></script>
<script type="text/javascript" src="../../../../scripts/symbol-parameters-wrapper_deferred.js" defer></script></head>
<body>
    <div class="root">
<nav class="navigation" id="navigation-wrapper">
    <div class="navigation--inner">
        <div class="navigation-title">
            <button class="menu-toggle" id="menu-toggle" type="button">toggle menu</button>
            <div class="library-name">
<a class="library-name--link" href="../../../../index.html">
                            exposed
                    </a>            </div>
            <div class="library-version">0.57.0
            </div>
        </div>
        <div class="filter-section" id="filter-section">
                <button class="platform-tag platform-selector jvm-like" data-active="" data-filter=":exposed-core:dokkaHtmlPartial/main">jvm</button>
        </div>
    </div>
    <div class="navigation-controls">
        <button class="navigation-controls--btn navigation-controls--theme" id="theme-toggle-button" type="button">switch theme</button>
        <div class="navigation-controls--btn navigation-controls--search" id="searchBar" role="button">search in API</div>
    </div>
</nav>
        <div id="container">
            <div class="sidebar" id="leftColumn">
                <div class="sidebar--inner" id="sideMenu"></div>
            </div>
            <div id="main">
<div class="main-content" data-page-type="member" id="content" pageids="exposed-core::org.jetbrains.exposed.sql/Database.Companion/connect/#javax.sql.DataSource#kotlin.Function1[java.sql.Connection,kotlin.Unit]#org.jetbrains.exposed.sql.DatabaseConfig?#org.jetbrains.exposed.sql.DatabaseConnectionAutoRegistration#kotlin.Function1[org.jetbrains.exposed.sql.Database,org.jetbrains.exposed.sql.transactions.TransactionManager]/PointingToDeclaration//-1583301284">
  <div class="breadcrumbs"><a href="../../../index.html">exposed-core</a><span class="delimiter">/</span><a href="../../index.html">org.jetbrains.exposed.sql</a><span class="delimiter">/</span><a href="../index.html">Database</a><span class="delimiter">/</span><a href="index.html">Companion</a><span class="delimiter">/</span><span class="current">connect</span></div>
  <div class="cover ">
    <h1 class="cover"><span><span>connect</span></span></h1>
  </div>
  <div class="platform-hinted " data-platform-hinted="data-platform-hinted"><div class="content sourceset-dependent-content" data-active="" data-togglable=":exposed-core:dokkaHtmlPartial/main"><div class="symbol monospace"><span class="token keyword">fun </span><a href="connect.html"><span class="token function">connect</span></a><span class="token punctuation">(</span><span class="parameters "><span class="parameter ">datasource<span class="token operator">: </span><a href="https://docs.oracle.com/javase/8/docs/api/javax/sql/DataSource.html">DataSource</a><span class="token punctuation">, </span></span><span class="parameter ">setupConnection<span class="token operator">: </span><span class="token punctuation">(</span><a href="https://docs.oracle.com/javase/8/docs/api/java/sql/Connection.html">Connection</a><span class="token punctuation">)</span><span class="token operator"> -&gt; </span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a><span class="token operator"> = </span>{}<span class="token punctuation">, </span></span><span class="parameter ">databaseConfig<span class="token operator">: </span><a href="../../-database-config/index.html">DatabaseConfig</a><span class="token operator">?</span><span class="token operator"> = </span>null<span class="token punctuation">, </span></span><span class="parameter ">connectionAutoRegistration<span class="token operator">: </span><a href="../../-database-connection-auto-registration/index.html">DatabaseConnectionAutoRegistration</a><span class="token operator"> = </span>connectionInstanceImpl<span class="token punctuation">, </span></span><span class="parameter ">manager<span class="token operator">: </span><span class="token punctuation">(</span><a href="../index.html">Database</a><span class="token punctuation">)</span><span class="token operator"> -&gt; </span><a href="../../../org.jetbrains.exposed.sql.transactions/-transaction-manager/index.html">TransactionManager</a><span class="token operator"> = </span>{ ThreadLocalTransactionManager(it) }</span></span><span class="token punctuation">)</span><span class="token operator">: </span><a href="../index.html">Database</a></div><p class="paragraph">Creates a <a href="../index.html">Database</a> instance.</p><p class="paragraph"><strong>Note:</strong> This function does not immediately instantiate an actual connection to a database, but instead provides the details necessary to do so whenever a connection is required by a transaction.</p><h4 class="">Parameters</h4><div class="table"><div class="table-row" data-filterable-current=":exposed-core:dokkaHtmlPartial/main" data-filterable-set=":exposed-core:dokkaHtmlPartial/main"><div class="main-subrow keyValue "><div class=""><span class="inline-flex"><div><u><span><span>datasource</span></span></u></div></span></div><div><div class="title"><p class="paragraph">The <a href="https://docs.oracle.com/javase/8/docs/api/javax/sql/DataSource.html">DataSource</a> object to be used as a means of getting a connection.</p></div></div></div></div><div class="table-row" data-filterable-current=":exposed-core:dokkaHtmlPartial/main" data-filterable-set=":exposed-core:dokkaHtmlPartial/main"><div class="main-subrow keyValue "><div class=""><span class="inline-flex"><div><u><span>connection</span><wbr><span>Auto</span><wbr><span><span>Registration</span></span></u></div></span></div><div><div class="title"><p class="paragraph">The connection provider for database. If not provided, a service loader will be used to locate and load a provider for <a href="../../-database-connection-auto-registration/index.html">DatabaseConnectionAutoRegistration</a>.</p></div></div></div></div><div class="table-row" data-filterable-current=":exposed-core:dokkaHtmlPartial/main" data-filterable-set=":exposed-core:dokkaHtmlPartial/main"><div class="main-subrow keyValue "><div class=""><span class="inline-flex"><div><u><span>setup</span><wbr><span><span>Connection</span></span></u></div></span></div><div><div class="title"><p class="paragraph">Any setup that should be applied to each new connection.</p></div></div></div></div><div class="table-row" data-filterable-current=":exposed-core:dokkaHtmlPartial/main" data-filterable-set=":exposed-core:dokkaHtmlPartial/main"><div class="main-subrow keyValue "><div class=""><span class="inline-flex"><div><u><span>database</span><wbr><span><span>Config</span></span></u></div></span></div><div><div class="title"><p class="paragraph">Configuration parameters for this <a href="../index.html">Database</a> instance.</p></div></div></div></div><div class="table-row" data-filterable-current=":exposed-core:dokkaHtmlPartial/main" data-filterable-set=":exposed-core:dokkaHtmlPartial/main"><div class="main-subrow keyValue "><div class=""><span class="inline-flex"><div><u><span><span>manager</span></span></u></div></span></div><div><div class="title"><p class="paragraph">The <a href="../../../org.jetbrains.exposed.sql.transactions/-transaction-manager/index.html">TransactionManager</a> responsible for new transactions that use this <a href="../index.html">Database</a> instance.</p></div></div></div></div></div><hr><div class="symbol monospace"><span class="token keyword">fun </span><a href="connect.html"><span class="token function">connect</span></a><span class="token punctuation">(</span><span class="parameters "><span class="parameter ">getNewConnection<span class="token operator">: </span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token operator"> -&gt; </span><a href="https://docs.oracle.com/javase/8/docs/api/java/sql/Connection.html">Connection</a><span class="token punctuation">, </span></span><span class="parameter ">databaseConfig<span class="token operator">: </span><a href="../../-database-config/index.html">DatabaseConfig</a><span class="token operator">?</span><span class="token operator"> = </span>null<span class="token punctuation">, </span></span><span class="parameter ">connectionAutoRegistration<span class="token operator">: </span><a href="../../-database-connection-auto-registration/index.html">DatabaseConnectionAutoRegistration</a><span class="token operator"> = </span>connectionInstanceImpl<span class="token punctuation">, </span></span><span class="parameter ">manager<span class="token operator">: </span><span class="token punctuation">(</span><a href="../index.html">Database</a><span class="token punctuation">)</span><span class="token operator"> -&gt; </span><a href="../../../org.jetbrains.exposed.sql.transactions/-transaction-manager/index.html">TransactionManager</a><span class="token operator"> = </span>{ ThreadLocalTransactionManager(it) }</span></span><span class="token punctuation">)</span><span class="token operator">: </span><a href="../index.html">Database</a></div><p class="paragraph">Creates a <a href="../index.html">Database</a> instance.</p><p class="paragraph"><strong>Note:</strong> This function does not immediately instantiate an actual connection to a database, but instead provides the details necessary to do so whenever a connection is required by a transaction.</p><h4 class="">Parameters</h4><div class="table"><div class="table-row" data-filterable-current=":exposed-core:dokkaHtmlPartial/main" data-filterable-set=":exposed-core:dokkaHtmlPartial/main"><div class="main-subrow keyValue "><div class=""><span class="inline-flex"><div><u><span>get</span><wbr><span>New</span><wbr><span><span>Connection</span></span></u></div></span></div><div><div class="title"><p class="paragraph">A function that returns a new connection.</p></div></div></div></div><div class="table-row" data-filterable-current=":exposed-core:dokkaHtmlPartial/main" data-filterable-set=":exposed-core:dokkaHtmlPartial/main"><div class="main-subrow keyValue "><div class=""><span class="inline-flex"><div><u><span>connection</span><wbr><span>Auto</span><wbr><span><span>Registration</span></span></u></div></span></div><div><div class="title"><p class="paragraph">The connection provider for database. If not provided, a service loader will be used to locate and load a provider for <a href="../../-database-connection-auto-registration/index.html">DatabaseConnectionAutoRegistration</a>.</p></div></div></div></div><div class="table-row" data-filterable-current=":exposed-core:dokkaHtmlPartial/main" data-filterable-set=":exposed-core:dokkaHtmlPartial/main"><div class="main-subrow keyValue "><div class=""><span class="inline-flex"><div><u><span>database</span><wbr><span><span>Config</span></span></u></div></span></div><div><div class="title"><p class="paragraph">Configuration parameters for this <a href="../index.html">Database</a> instance.</p></div></div></div></div><div class="table-row" data-filterable-current=":exposed-core:dokkaHtmlPartial/main" data-filterable-set=":exposed-core:dokkaHtmlPartial/main"><div class="main-subrow keyValue "><div class=""><span class="inline-flex"><div><u><span><span>manager</span></span></u></div></span></div><div><div class="title"><p class="paragraph">The <a href="../../../org.jetbrains.exposed.sql.transactions/-transaction-manager/index.html">TransactionManager</a> responsible for new transactions that use this <a href="../index.html">Database</a> instance.</p></div></div></div></div></div><hr><div class="symbol monospace"><span class="token keyword">fun </span><a href="connect.html"><span class="token function">connect</span></a><span class="token punctuation">(</span><span class="parameters "><span class="parameter ">url<span class="token operator">: </span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html">String</a><span class="token punctuation">, </span></span><span class="parameter ">driver<span class="token operator">: </span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html">String</a><span class="token operator"> = </span>getDriver(url)<span class="token punctuation">, </span></span><span class="parameter ">user<span class="token operator">: </span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html">String</a><span class="token operator"> = </span><span class="token string">""</span><span class="token punctuation">, </span></span><span class="parameter ">password<span class="token operator">: </span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html">String</a><span class="token operator"> = </span><span class="token string">""</span><span class="token punctuation">, </span></span><span class="parameter ">setupConnection<span class="token operator">: </span><span class="token punctuation">(</span><a href="https://docs.oracle.com/javase/8/docs/api/java/sql/Connection.html">Connection</a><span class="token punctuation">)</span><span class="token operator"> -&gt; </span><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a><span class="token operator"> = </span>{}<span class="token punctuation">, </span></span><span class="parameter ">databaseConfig<span class="token operator">: </span><a href="../../-database-config/index.html">DatabaseConfig</a><span class="token operator">?</span><span class="token operator"> = </span>null<span class="token punctuation">, </span></span><span class="parameter ">connectionAutoRegistration<span class="token operator">: </span><a href="../../-database-connection-auto-registration/index.html">DatabaseConnectionAutoRegistration</a><span class="token operator"> = </span>connectionInstanceImpl<span class="token punctuation">, </span></span><span class="parameter ">manager<span class="token operator">: </span><span class="token punctuation">(</span><a href="../index.html">Database</a><span class="token punctuation">)</span><span class="token operator"> -&gt; </span><a href="../../../org.jetbrains.exposed.sql.transactions/-transaction-manager/index.html">TransactionManager</a><span class="token operator"> = </span>{ ThreadLocalTransactionManager(it) }</span></span><span class="token punctuation">)</span><span class="token operator">: </span><a href="../index.html">Database</a></div><p class="paragraph">Creates a <a href="../index.html">Database</a> instance.</p><p class="paragraph"><strong>Note:</strong> This function does not immediately instantiate an actual connection to a database, but instead provides the details necessary to do so whenever a connection is required by a transaction.</p><h4 class="">Parameters</h4><div class="table"><div class="table-row" data-filterable-current=":exposed-core:dokkaHtmlPartial/main" data-filterable-set=":exposed-core:dokkaHtmlPartial/main"><div class="main-subrow keyValue "><div class=""><span class="inline-flex"><div><u><span><span>url</span></span></u></div></span></div><div><div class="title"><p class="paragraph">The URL that represents the database when getting a connection.</p></div></div></div></div><div class="table-row" data-filterable-current=":exposed-core:dokkaHtmlPartial/main" data-filterable-set=":exposed-core:dokkaHtmlPartial/main"><div class="main-subrow keyValue "><div class=""><span class="inline-flex"><div><u><span>connection</span><wbr><span>Auto</span><wbr><span><span>Registration</span></span></u></div></span></div><div><div class="title"><p class="paragraph">The connection provider for database. If not provided, a service loader will be used to locate and load a provider for <a href="../../-database-connection-auto-registration/index.html">DatabaseConnectionAutoRegistration</a>.</p></div></div></div></div><div class="table-row" data-filterable-current=":exposed-core:dokkaHtmlPartial/main" data-filterable-set=":exposed-core:dokkaHtmlPartial/main"><div class="main-subrow keyValue "><div class=""><span class="inline-flex"><div><u><span><span>driver</span></span></u></div></span></div><div><div class="title"><p class="paragraph">The JDBC driver class. If not provided, the specified <a href="connect.html">url</a> will be used to find a match from the existing driver mappings.</p></div></div></div></div><div class="table-row" data-filterable-current=":exposed-core:dokkaHtmlPartial/main" data-filterable-set=":exposed-core:dokkaHtmlPartial/main"><div class="main-subrow keyValue "><div class=""><span class="inline-flex"><div><u><span><span>user</span></span></u></div></span></div><div><div class="title"><p class="paragraph">The database user that owns the new connections.</p></div></div></div></div><div class="table-row" data-filterable-current=":exposed-core:dokkaHtmlPartial/main" data-filterable-set=":exposed-core:dokkaHtmlPartial/main"><div class="main-subrow keyValue "><div class=""><span class="inline-flex"><div><u><span><span>password</span></span></u></div></span></div><div><div class="title"><p class="paragraph">The password specific for the database <a href="connect.html">user</a>.</p></div></div></div></div><div class="table-row" data-filterable-current=":exposed-core:dokkaHtmlPartial/main" data-filterable-set=":exposed-core:dokkaHtmlPartial/main"><div class="main-subrow keyValue "><div class=""><span class="inline-flex"><div><u><span>setup</span><wbr><span><span>Connection</span></span></u></div></span></div><div><div class="title"><p class="paragraph">Any setup that should be applied to each new connection.</p></div></div></div></div><div class="table-row" data-filterable-current=":exposed-core:dokkaHtmlPartial/main" data-filterable-set=":exposed-core:dokkaHtmlPartial/main"><div class="main-subrow keyValue "><div class=""><span class="inline-flex"><div><u><span>database</span><wbr><span><span>Config</span></span></u></div></span></div><div><div class="title"><p class="paragraph">Configuration parameters for this <a href="../index.html">Database</a> instance.</p></div></div></div></div><div class="table-row" data-filterable-current=":exposed-core:dokkaHtmlPartial/main" data-filterable-set=":exposed-core:dokkaHtmlPartial/main"><div class="main-subrow keyValue "><div class=""><span class="inline-flex"><div><u><span><span>manager</span></span></u></div></span></div><div><div class="title"><p class="paragraph">The <a href="../../../org.jetbrains.exposed.sql.transactions/-transaction-manager/index.html">TransactionManager</a> responsible for new transactions that use this <a href="../index.html">Database</a> instance.</p></div></div></div></div></div></div></div>
</div>
      <div class="footer">
        <span class="go-to-top-icon"><a href="#content" id="go-to-top-link"></a></span><span>© 2024 Copyright</span><span class="pull-right"><span>Generated by </span><a href="https://github.com/Kotlin/dokka"><span>dokka</span><span class="padded-icon"></span></a></span>
      </div>
            </div>
        </div>
    </div>
</body>
</html>

